package com.stock.stockana.ui.activities;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;

import com.stock.publiclib.BaseActivity;
import com.stock.stockana.R;

import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;

/**
 * ---------------------------------------------------
 * Description:
 * Author: ljgsonx
 * Belong to: com.stock.stockana.ui.activities
 * Time: 2016/3/17 10:12
 * ---------------------------------------------------
 */
public class NotReadyActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setFragmentContentView(LayoutInflater.from(this).inflate(R.layout.notready_layout, null, false));
        setToolbarPosTitle("Sorry =-=");
        removeToolbarMenu();
        if(getSupportActionBar() != null){
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            onBackPressed();
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onBackPressed() {
        if(getSupportFragmentManager().getBackStackEntryCount() > 1) {
            getSupportFragmentManager().popBackStackImmediate();
        }else{
            finish();
            overridePendingTransition(R.anim.in_from_left, R.anim.out_from_right);
            if(MainActivity.instance == null){
                startActivity(new Intent(this, MainActivity.class));
            }
        }
    }

    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
    }
}
